package priority;

/**
 * 线程优先级设置
 */
public class PriorityDemo implements Runnable {
    @Override
    public void run() {
        while (true) {
            System.out.println(Thread.currentThread().getName());
        }
    }

    public static void main(String[] args) {
        Thread thread1 = new Thread(new PriorityDemo(), "线程1");
        Thread thread2 = new Thread(new PriorityDemo(), "线程2");
        //设置线程的优先级
        thread1.setPriority(Thread.MAX_PRIORITY);
        thread2.setPriority(Thread.MIN_PRIORITY);
        thread1.start();
        thread2.start();
    }
}
